class Solution {
public:
    int numRescueBoats(vector<int>& people, int limit)
    {
        //如果加起来大的话就把右边的放进去  如果小于等于就放俩
        int ans = 0;
        ranges::sort(people);
        int left = 0;
        int right = people.size() - 1;
        while (left <= right)
        {
            if (people[left] + people[right] <= limit) left++;
            right--;
            ans++;
        }
        return ans;
    }
};